/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package bpmn.impl;

import bpmn.Artifact;
import bpmn.ArtifactInput;
import bpmn.BpmnPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Artifact Input</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link bpmn.impl.ArtifactInputImpl#getArtifactRef <em>Artifact Ref</em>}</li>
 *   <li>{@link bpmn.impl.ArtifactInputImpl#getRequiredForStart <em>Required For Start</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ArtifactInputImpl extends BPMNElementImpl implements ArtifactInput {
	/**
	 * The cached value of the '{@link #getArtifactRef() <em>Artifact Ref</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getArtifactRef()
	 * @generated
	 * @ordered
	 */
	protected Artifact artifactRef;

	/**
	 * The default value of the '{@link #getRequiredForStart() <em>Required For Start</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRequiredForStart()
	 * @generated
	 * @ordered
	 */
	protected static final String REQUIRED_FOR_START_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getRequiredForStart() <em>Required For Start</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRequiredForStart()
	 * @generated
	 * @ordered
	 */
	protected String requiredForStart = REQUIRED_FOR_START_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ArtifactInputImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return BpmnPackage.Literals.ARTIFACT_INPUT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Artifact getArtifactRef() {
		if (artifactRef != null && artifactRef.eIsProxy()) {
			InternalEObject oldArtifactRef = (InternalEObject)artifactRef;
			artifactRef = (Artifact)eResolveProxy(oldArtifactRef);
			if (artifactRef != oldArtifactRef) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, BpmnPackage.ARTIFACT_INPUT__ARTIFACT_REF, oldArtifactRef, artifactRef));
			}
		}
		return artifactRef;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Artifact basicGetArtifactRef() {
		return artifactRef;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setArtifactRef(Artifact newArtifactRef) {
		Artifact oldArtifactRef = artifactRef;
		artifactRef = newArtifactRef;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.ARTIFACT_INPUT__ARTIFACT_REF, oldArtifactRef, artifactRef));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getRequiredForStart() {
		return requiredForStart;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setRequiredForStart(String newRequiredForStart) {
		String oldRequiredForStart = requiredForStart;
		requiredForStart = newRequiredForStart;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.ARTIFACT_INPUT__REQUIRED_FOR_START, oldRequiredForStart, requiredForStart));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case BpmnPackage.ARTIFACT_INPUT__ARTIFACT_REF:
				if (resolve) return getArtifactRef();
				return basicGetArtifactRef();
			case BpmnPackage.ARTIFACT_INPUT__REQUIRED_FOR_START:
				return getRequiredForStart();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case BpmnPackage.ARTIFACT_INPUT__ARTIFACT_REF:
				setArtifactRef((Artifact)newValue);
				return;
			case BpmnPackage.ARTIFACT_INPUT__REQUIRED_FOR_START:
				setRequiredForStart((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case BpmnPackage.ARTIFACT_INPUT__ARTIFACT_REF:
				setArtifactRef((Artifact)null);
				return;
			case BpmnPackage.ARTIFACT_INPUT__REQUIRED_FOR_START:
				setRequiredForStart(REQUIRED_FOR_START_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case BpmnPackage.ARTIFACT_INPUT__ARTIFACT_REF:
				return artifactRef != null;
			case BpmnPackage.ARTIFACT_INPUT__REQUIRED_FOR_START:
				return REQUIRED_FOR_START_EDEFAULT == null ? requiredForStart != null : !REQUIRED_FOR_START_EDEFAULT.equals(requiredForStart);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (RequiredForStart: ");
		result.append(requiredForStart);
		result.append(')');
		return result.toString();
	}

} //ArtifactInputImpl
